export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}

cd
git clone https://gitee.com/open3dv/galaxy-linux-armhf.git
cd galaxy-linux-armhf
tar xvf Galaxy_Linux-armhf_Gige-U3_32bits-64bits_1.3.2111.9261.tar.gz
cd Galaxy_Linux-armhf_Gige-U3_32bits-64bits_1.3.2111.9261
sudo ./Galaxy_camera.run
cd
rm -rf galaxy-linux-armhf

cd
git clone https://gitee.com/open3dv/basler_linux_arm64.git
cd basler_linux_arm64/
sudo mkdir /opt/pylon
sudo tar -C /opt/pylon -xzf ./pylon_*.tar.gz
sudo chmod 755 /opt/pylon
yes y | sudo ./opt/pylon/share/pylon/setup-usb.sh
cd
rm -rf basler_linux_arm64/

cd
git clone https://gitee.com/loing/xema.git --depth=1 -b dev
git clone https://gitee.com/open3dv/thirdparty.git --depth=1 
echo 'copying opencv libs...'
mkdir xema/3rdparty
cp -r thirdparty/linux-opencv-4.4.0 xema/3rdparty
cp -r thirdparty/JetsonGPIO xema/3rdparty
rm -rf thirdparty
cd xema/version
chmod +x build.sh
./build.sh
cd ../firmware
mkdir build
cd build
cmake ..
make -j4
cp /home/jetson/xema/3rdparty/linux-opencv-4.4.0/lib/* .
cd ../../update
mkdir build
cd build
cmake ..
make 

cd 
git clone https://gitee.com/open3dv/ConfiguringIP.git
cd ConfiguringIP/version
chmod +x build.sh
./build.sh
cd ../firmware
mkdir build
cd build
cmake ..
make -j4

echo '#!/bin/bash' > rc.local
echo 'cd /home/jetson/xema/firmware/build' >> rc.local
echo './camera_server &' >> rc.local
echo 'cd /home/jetson/ConfiguringIP/firmware/build' >> rc.local
echo './configuring_ip &' >> rc.local

sudo cp rc.local /etc
sudo chmod +x /etc/rc.local

echo "Configration completed!"
